<?php
/*
*   Template Name: Contact Template
*/
if($_POST['submitcontact']=="submitted"){

		$name=$_POST['first-name'].' '.$_POST['last-name'];
		$phone=$_POST['phone'];
		$email=$_POST['email'];
		$comments=$_POST['comment'];
        $topic=$_POST['topic'];
		$location=$_POST['location'];
		$server=$_POST['server'];
		$datecontact=$_POST['datecontact'];
		$timecontact=$_POST['timecontact'];
		$check=$_POST['check'];
		
		$topic_email_option=my_option('topic_email');
		$topic_email_ex=explode(',',$topic_email_option);
		foreach($topic_email_ex as $topic_email){
			$topic_email_pc=explode('|',$topic_email);
			if(trim($topic_email_pc[0])==$topic){
				$emailTo =	$topic_email_pc[1];
				$short=$topic_email_pc[2];
			}
		}
		       $subject = 'From '.$name;
               $body = "<b>Contact Info :</b>\n\n
			   			Name: $name \n\n
			   			Phone: $phone \n\n
						Email: $email \n\n
						<b>This is regarding a...</b>\n\n
						Topic: $topic \n\n";
				if(!isset($short)){
						$body .="
			   			Location: $location \n\n
			   			Server / Cashier: $server \n\n
			   			Date (mm/dd/yy) : $datecontact \n\n
						Time : $timecontact \n\n
			   			Check #: $check \n\n";
				}
			   	$body .="		
						Comments: $comments";
               $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;
               wp_mail($emailTo, $subject, $body, $headers);
               $emailSent = true;
				
}else{
		$emailSent = false;
}	


get_header();
?>
<script type="text/javascript">
$(function(){

	$("#date_arr").datepicker({
		dateFormat: 'mm/dd/yy',
		minDate:1,
	})	
	
});

</script>

<div class="group slider">	
			<?php //echo do_shortcode("[metaslider id=18]"); ?>
			</div>
			<div id="primary" class="site-content-resto">
		<div id="content" role="main">
			<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', 'contact' ); ?>
			<?php endwhile; // end of the loop. ?>
		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_footer(); ?>            